<template>
	<u-popup v-model="showSelf" 
      mode="bottom" 
      border-radius="14" 
      :closeable="true" 
      :safe-area-inset-bottom="true"
      @close="onClose" 
    >
		<view class="bg-white contain">
			<view class="header">
				配件
			</view>
            <!-- 规格 -->
			<view class="main">
				<scroll-view style="max-height: 600rpx;" scroll-y="true">
					<view>
						<view v-for="(item, index) in accessoryLists" :key="index" class="list">
							<view class="mb20">{{ item.name }}</view>
							<view v-for="(item2, index2) in item.accessory_item" :key="index2" class="item" >
								<view class="flex1 line1">{{ item2.name }}</view>
								<view class="row">
									<view class="mr20 price" v-if="Number(item2.price)!=0">￥{{ item2.price }}</view>
									<view>*{{ item2.num }}</view>
								</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
			
			<!-- 底部按钮 -->
			<view class="btns row-between bg-white">
				
				<!-- #ifndef MP-ALIPAY -->
				<button class="bg-primary br60 white btn" size="lg" @tap="onClose">确定</button>
				<!-- #endif -->
				
				<!-- #ifdef MP-ALIPAY -->
				<view class="bg-primary br60 white btn alipay-btn" size="lg" @tap="onClose">确定</view>
				<!-- #endif -->
			</view>
		</view>
	</u-popup>
</template>

<script>
	export default {
        props: {
        	show: {
        		type: Boolean
        	},
        	accessory: {
        		type: Array,
                value: []
        	},
        },
        
		data() {
			return {
				showSelf: false, // 是否显示自身Popup
                accessoryLists: [], // 配件信息
			};
		},
        
		watch: {
			// 数据初始化
			accessory(value) {
				this.accessoryLists = value;
			},
			
			show(val) {
				this.showSelf = val
			},
		},
		
		methods: {
           onClose() {
				this.$emit('close')
           },
		},
	};
</script>
<style lang="scss" scoped>
	.contain {
		border-radius: 10rpx 10rpx 0 0;
		overflow: hidden;
		position: relative;

		.close {
			position: absolute;
			right: 10rpx;
			top: 10rpx;
		}

		.header {
			padding: 30rpx 0;
			text-align: center;
			font-size: 32rpx;
		}

		.main {
			padding: 30rpx 44rpx;
			.list {
				margin-bottom: 40rpx;
				.item {
					padding: 20rpx 30rpx;
					margin-bottom: 20rpx;
					border-radius: 16rpx;
					background-color: #F6F6F8;
					font-size: 28rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;
					.price {
						opacity: .5;
						text-decoration: line-through;
					}
				}
			}
		}
		
		.btns {
			height: 120rpx;
			padding: 0 30rpx;
			// margin-top: 80rpx;
		
			.add-cart {
				background-color: rgba(36, 163, 255, 0.1);
			}
		
			.btn {
				margin: 0 10rpx;
				flex: 1;
			}
			
			.alipay-btn {
				height: 80rpx;
				line-height: 80rpx;
				padding: 0 30rpx;
				text-align: center;
				font-size: 32rpx;
			}
		}
	}
</style>
